package fr.resasante.exception;

import org.jboss.logging.Logger;

import fr.resasante.utils.CommonUtils;

/**
 * Exception class for front errors
 * 
 * @author GEFFROY-DE-VILLEBLAN
 * 
 */
public class ApplicationException extends RuntimeException {
	/**
	 * Serial version ID
	 */
	private static final long serialVersionUID = 9131563185044284493L;

	/**
	 * Logger for the class
	 */
	private static final Logger logger = Logger
			.getLogger(ApplicationException.class.getName());

	/**
	 * Constructor
	 * 
	 * @param message
	 *            Error message
	 */
	public ApplicationException(final String message) {
		super(message);
		logMessage(message);
	}

	/**
	 * Constructor
	 * 
	 * @param message
	 *            Error message
	 * @param cause
	 *            Error cause
	 */
	public ApplicationException(final String message, final Throwable cause) {
		super(message, cause);
		logMessage(message);
		logger.error(CommonUtils.getInstance().getStackTrace(cause));
	}

	/**
	 * Log message via logger
	 * 
	 * @param message
	 *            Error message
	 */
	private void logMessage(final String message) {
		logger.error(message);
	}
}
